#!/bin/sh
#
# common procedures for the PMNS scripts
#
# $Revision: 2.1 $

# find cpp
#
CPP=''
for file in /lib/cpp /usr/lib/cpp \
	    /usr/cpu/sysgen/root/lib/cpp \
	    /usr/cpu/sysgen/root/usr/lib/cpp
do
    if [ -x $file ]
    then
	CPP=$file
	break
    fi
done
if [ -z "$CPP" ]
then
    echo "$prog: cannot locate \"cpp\", cannot proceed"
    exit
fi

# add -Uname controls to avoid translating any valid PCP name component
# ... see cpp(1)
#
CPP="$CPP -Usgi -Uunix -Umips"

_can_load_ascii()
{
    if [ -x /usr/pcp/bin/pmbrand ]
    then
	/usr/pcp/bin/pmbrand -l 2>&1 | sed '/^Licenses /d' >/tmp/$$.tmp
	if [ -s /tmp/$$.tmp ]
	then
	    # at least one PCP license of some sort
	    if grep 'PCP ' /tmp/$$.tmp >/dev/null
	    then
		# PCP Monitor or PCP Collector
		:
	    else
		# license does not permit PMNS rebuild, skip it
		rm -f /tmp/$$.tmp
		return 1
	    fi
	else
	    # no PCP license => can load ASCII PMNS
	    :
	fi
	rm -f /tmp/$$.tmp
    fi
    return 0
}
